package model

import "gorm.io/gorm"

// Post 是用户发布的 Post 中包含的内容
type Post struct {
	gorm.Model
	PostContent
	Likes    int64     `gorm:"default:0" json:"likes"`
	User     *User     `gorm:"foreignKey:AuthorID" json:"user,omitempty"`   // 关联到 User 表
	Comments []Comment `gorm:"foreignKey:PostID" json:"comments,omitempty"` // 关联到 Comment 表
}

type PostContent struct {
	Title    string `binding:"required" json:"title,omitempty"`
	Topic    string `binding:"required" json:"topic,omitempty"`
	AuthorID uint   `binding:"required" json:"authorID,omitempty"`
	Content  string `binding:"required" json:"content,omitempty"`
}

// PostEdit 是用户编辑 Post 时提交的内容
// 太丑陋了😭, goland 怎么不支持 emoji，烂
type PostEdit struct {
	Title   string `json:"title,omitempty"`
	Topic   string `json:"topic,omitempty"`
	Content string `json:"content,omitempty"`
}
